import Router from 'koa-router';
import proxyService from '../../../common/proxyService';
import {
  fissionValidCssAppAccountType,
  fissionQueryCssGroup,
  fissionSaveOrUpdateGroup,
  fissionDeleteGroup,
  fissionUpdateGroupOrder,
  fissionGetPosterTemplateByPage,
  fissionUpdatePosterTemplateGroup,
  fissionDeletePosterTemplate,
  fissionUpdateGetPosterCloudToken,
  fissionSaveOrUpdatePosterTemplate,
  fissionGetPosterTemplate,
  fissionQueryPosterByPage,
  fissionGetFansPosterImageById,
  fissionGetPosterStatistics,
  fissionGetPosterStatisticsList,
  fissionGetPosterTemplateStatistics,
  fissionGetPosterTemplateStatisticsList,
  fissionGetActivityTaskStatistics,
  fissionGetPosterTaskStatistics,
  fissionGetTemplateLevelStatistics,
  fissionQueryBoostList,
  fissionGetEedata,
  // getFissionPosterRankList,
} from '../../../api';

const router = new Router();

router.get('/validCssAppAccountType', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionValidCssAppAccountType);
  return (ctx.body = response);
});

router.get('/queryCssGroup', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionQueryCssGroup);
  return (ctx.body = response);
});

router.post('/saveOrUpdateGroup', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionSaveOrUpdateGroup);
  return (ctx.body = response);
});

router.post('/deleteGroup', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionDeleteGroup);
  return (ctx.body = response);
});
router.post('/updateGroupOrder', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionUpdateGroupOrder);
  return (ctx.body = response);
});

router.get('/getPosterTemplateByPage', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterTemplateByPage);
  return (ctx.body = response);
});

router.post('/updatePosterTemplateGroup', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionUpdatePosterTemplateGroup);
  return (ctx.body = response);
});
router.post('/deletePosterTemplate', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionDeletePosterTemplate);
  return (ctx.body = response);
});
router.post('/updateGetPosterCloudToken', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionUpdateGetPosterCloudToken);
  return (ctx.body = response);
});
router.post('/saveOrUpdatePosterTemplate', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionSaveOrUpdatePosterTemplate);
  return (ctx.body = response);
});
router.get('/getPosterTemplate', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterTemplate);
  return (ctx.body = response);
});

router.get('/queryPosterByPage', async ctx => {
  ctx.requestParams.mission = ctx.requestParams.mission
    ? JSON.parse(ctx.requestParams.mission)
    : [];
  const response = await proxyService.postProxy(ctx, fissionQueryPosterByPage);
  return (ctx.body = response);
});
router.get('/getFansPosterImageById', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetFansPosterImageById);
  return (ctx.body = response);
});
router.get('/getPosterStatistics', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterStatistics);
  return (ctx.body = response);
});
router.get('/getPosterStatisticsList', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterStatisticsList);
  return (ctx.body = response);
});
router.get('/getPosterTemplateStatistics', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterTemplateStatistics);
  return (ctx.body = response);
});
router.get('/getPosterTemplateStatisticsList', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterTemplateStatisticsList);
  return (ctx.body = response);
});
router.get('/getActivityTaskStatistics', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetActivityTaskStatistics);
  return (ctx.body = response);
});
router.get('/getPosterTaskStatistics', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetPosterTaskStatistics);
  return (ctx.body = response);
});
router.get('/getTemplateLevelStatistics', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetTemplateLevelStatistics);
  return (ctx.body = response);
});

router.get('/queryBoostList', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionQueryBoostList);
  return (ctx.body = response);
});

router.get('/getEedata', async ctx => {
  const response = await proxyService.postProxy(ctx, fissionGetEedata);
  return (ctx.body = response);
});

router.get('/getPosterRankList', async ctx => {
  //
  // let response = await proxyService.postProxy(ctx, getFissionPosterRankList);
  // console.log(response)
  // if (response.code === 1 && response.data.dtarankPositionInfoDtos.length ) {
  //   response.data.records = (response.data.dtarankPositionInfoDtos || []).map(i => ({
  //     ...i,
  //     fansNickname: i.nickname,
  //     fansName: i.name,
  //     boostNum:
  //   }))
  // }
  const response = await proxyService.mockData({
    code: 1,
    message: 'delete ok',
    data: {
      'records|5': [
        {
          'id|+1': 1,
          name: '123',
          headImageUrl: 'https://xiaodashi.com/logo.png',
          fansName: 'xw',
          fansNickname: '3333',
          'boostNum|+3': 2,
        },
      ],
    },
  });
  return (ctx.body = response);
});

export default router;
